From 12e8349571260c684c63f1b772adde2ac74aed5e Mon Sep 17 00:00:00 2001 From: Platonides Date: Mon, 22 Mar 2010 22:28:15 +0000 Subject: [PATCH] RevisionDeleter has added i18n to his friends list. (bug 22903) Revdelete log entries now show in the user preferred language. --- RELEASE-NOTES | 1 + includes/LogPage.php | 13 +++-- includes/specials/SpecialRevisiondelete.php | 60 ++++++++++++++------- 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d6e7564e57..dc456145b5 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -54,6 +54,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 22772) {{#special:}} parser function now works with subpages * (bug 18664) Relative URIs in interwiki links cause failed redirects * (bug 19270) Relative URIs in interwiki links break interwiki transclusion +* (bug 22903) Revdelete log entries now show in the user preferred language. == API changes in 1.17 == * (bug 22738) Allow filtering by action type on query=logevent diff --git a/includes/LogPage.php b/includes/LogPage.php index 1d8d6c1c30..62eb3823ed 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -159,11 +159,13 @@ class LogPage { public static function logHeader( $type ) { global $wgLogHeaders, $wgMessageCache; $wgMessageCache->loadAllMessages(); - return wfMsgExt($wgLogHeaders[$type],array('parseinline')); + return wfMsgExt($wgLogHeaders[$type], array( 'parseinline' ) ); } /** * @static + * Note that if $skin is null, we want to use the wiki content language, since that + * will go to the irc feed. * @return HTML string */ public static function actionText( $type, $action, $title = null, $skin = null, @@ -217,6 +219,7 @@ class LogPage { } $params[2] = isset( $params[2] ) ? self::formatBlockFlags( $params[2], is_null( $skin ) ) : ''; + // Page protections } else if ( $type == 'protect' && count($params) == 3 ) { // Restrictions and expiries @@ -233,6 +236,7 @@ class LogPage { $details .= ' ['.wfMsgForContent('protect-summary-cascade').']'; } } + // Page moves } else if ( $type == 'move' && count( $params ) == 3 ) { if( $params[2] ) { @@ -242,19 +246,22 @@ class LogPage { $details .= ' [' . wfMsgForContent( 'move-redirect-suppressed' ) . ']'; } } + // Revision deletion } else if ( preg_match( '/^(delete|suppress)\/revision$/', $key ) && count( $params ) == 5 ) { $count = substr_count( $params[2], ',' ) + 1; // revisions $ofield = intval( substr( $params[3], 7 ) ); // $nfield = intval( substr( $params[4], 7 ) ); // - $details .= ': '.RevisionDeleter::getLogMessage( $count, $nfield, $ofield, false ); + $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, false, is_null($skin) ); + // Log deletion } else if ( preg_match( '/^(delete|suppress)\/event$/', $key ) && count( $params ) == 4 ) { $count = substr_count( $params[1], ',' ) + 1; // log items $ofield = intval( substr( $params[2], 7 ) ); // $nfield = intval( substr( $params[3], 7 ) ); // - $details .= ': '.RevisionDeleter::getLogMessage( $count, $nfield, $ofield, true ); + $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, true, is_null($skin) ); } + if ( $skin ) { $rv = wfMsgHtml( $wgLogActions[$key], $params ) . $details; } else { diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index b2db869c55..4e1edcdc33 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -621,12 +621,12 @@ class RevisionDeleter { } /** - * Gets an array describing the changes made to the visibilit of the revision. - * If the resulting array is $arr, then $arr[0] will contain an array of strings - * describing the items that were hidden, $arr[2] will contain an array of strings - * describing the items that were unhidden, and $arr[3] will contain an array with - * a single string, which can be one of "applied restrictions to sysops", - * "removed restrictions from sysops", or null. + * Gets an array of message keys describing the changes made to the visibility + * of the revision. If the resulting array is $arr, then $arr[0] will contain an + * array of strings describing the items that were hidden, $arr[2] will contain + * an array of strings describing the items that were unhidden, and $arr[3] will + * contain an array with a single string, which can be one of "applied + * restrictions to sysops", "removed restrictions from sysops", or null. * * @param $n Integer: the new bitfield. * @param $o Integer: the old bitfield. @@ -636,18 +636,18 @@ class RevisionDeleter { $diff = $n ^ $o; $ret = array( 0 => array(), 1 => array(), 2 => array() ); // Build bitfield changes in language - self::checkItem( wfMsgForContent( 'revdelete-content' ), + self::checkItem( 'revdelete-content', Revision::DELETED_TEXT, $diff, $n, $ret ); - self::checkItem( wfMsgForContent( 'revdelete-summary' ), + self::checkItem( 'revdelete-summary', Revision::DELETED_COMMENT, $diff, $n, $ret ); - self::checkItem( wfMsgForContent( 'revdelete-uname' ), + self::checkItem( 'revdelete-uname', Revision::DELETED_USER, $diff, $n, $ret ); // Restriction application to sysops if( $diff & Revision::DELETED_RESTRICTED ) { if( $n & Revision::DELETED_RESTRICTED ) - $ret[2][] = wfMsgForContent( 'revdelete-restricted' ); + $ret[2][] = 'revdelete-restricted'; else - $ret[2][] = wfMsgForContent( 'revdelete-unrestricted' ); + $ret[2][] = 'revdelete-unrestricted'; } return $ret; } @@ -661,24 +661,46 @@ class RevisionDeleter { * @param $nbitfield Integer: The new bitfield for the revision. * @param $obitfield Integer: The old bitfield for the revision. * @param $isForLog Boolean + * @param $forContent Boolean */ - public static function getLogMessage( $count, $nbitfield, $obitfield, $isForLog = false ) { - global $wgLang; + public static function getLogMessage( $count, $nbitfield, $obitfield, $isForLog = false, $forContent = false ) { + global $wgLang, $wgContLang; + + $lang = $forContent ? $wgContLang : $wgLang; + $msgFunc = $forContent ? "wfMsgForContent" : "wfMsg"; + $s = ''; $changes = self::getChanges( $nbitfield, $obitfield ); + array_walk($changes, 'RevisionDeleter::expandMessageArray', $forContent); + + $changesText = array(); + if( count( $changes[0] ) ) { - $s .= wfMsgForContent( 'revdelete-hid', implode( ', ', $changes[0] ) ); + $changesText[] = $msgFunc( 'revdelete-hid', $lang->commaList( $changes[0] ) ); } if( count( $changes[1] ) ) { - if ($s) $s .= '; '; - $s .= wfMsgForContent( 'revdelete-unhid', implode( ', ', $changes[1] ) ); + $changesText[] = $msgFunc( 'revdelete-unhid', $lang->commaList( $changes[1] ) ); } + + $s = $lang->semicolonList( $changesText ); if( count( $changes[2] ) ) { - $s .= $s ? ' (' . $changes[2][0] . ')' : $changes[2][0]; + $s .= $s ? ' (' . $changes[2][0] . ')' : ' ' . $changes[2][0]; } + $msg = $isForLog ? 'logdelete-log-message' : 'revdelete-log-message'; - return wfMsgExt( $msg, array( 'parsemag', 'content' ), $s, $wgLang->formatNum($count) ); - + return wfMsgExt( $msg, $forContent ? array( 'parsemag', 'content' ) : array( 'parsemag' ), $s, $lang->formatNum($count) ); + } + + private static function expandMessageArray(& $msg, $key, $forContent) { + if ( is_array ($msg) ) { + array_walk($msg, 'RevisionDeleter::expandMessageArray', $forContent); + } else { + if ( $forContent ) { + $msg = wfMsgForContent($msg); + } else { + $msg = wfMsg($msg); + } + } } // Get DB field name for URL param... -- 2.20.1